<template>
	<view class="container">
		<view class="card" @tap="gomap(item.cate_id)" v-for="(item,index) in listdata">
			<view class="top-box">
				<view class="top-title">
					任务名称：{{item.cate_name}}
				</view>
				<view class="tips" v-if="item.desc_status == 1">{{item.desc}}</view>
				<view class="tips" style="background: rgb(24, 210, 160);" v-if="item.desc_status == 2">{{item.desc}}</view>
				<view class="tips" style="background: rgb(108, 167, 255);" v-if="item.desc_status == 3">{{item.desc}}</view>
			</view>
			<view class="text">任务完成进度：{{item.num}}/{{item.total_num}}</view>
			<view class="text">任务完成周期：{{item.record_type_desc}}</view>
			<view class="text" v-if="item.record_type == 1">任务完成时间：{{item.record_time_one}}</view>
			<view class="text" v-if="item.record_type == 2">任务完成时间：{{item.record_time_two}}</view>
			<view class="text" v-if="item.record_type == 3">任务完成时间：{{item.record_time_three}}</view>
		</view>
		<view class="report" @click="goinspection">
			<image src="../../../static/images/historyList.png" class="publish-img"></image>
		</view>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const gettaskList = () => {
		common.post('HouseApi&a=my_task_list', {
			village_id: _this.village_id,
			page:1,
		}, data => {
			console.log('++++', data)
			_this.listdata = data.task_list;
		});
	};
	export default {
		data() {
			return {
				listdata: {},
				numlist: {},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				gettaskList()
			});
		},
		methods: {
			gomap(cate_id){
				uni.navigateTo({
					url:'/pages/village/smartQRcode/taskMap?cate_id=' + cate_id
				})
			},
			goinspection(){
				uni.navigateTo({
					url:'/pages/village/smartQRcode/inspectionRecords?map_type=' + 1
				})
			},
		},
		components: {

		}
	}
</script>

<style>
	page {
		background: rgb(245, 245, 245);
	}
	.container {
		margin: 0;
		padding: 0;
	}
	.card {
		background: #FFFFFF;
		margin: 30rpx;
		padding: 0rpx 20rpx 20rpx 20rpx;
		border-radius: 20rpx;
	}
	.top-box {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #F1F1F1;
		margin-bottom: 10rpx;
	}
	.top-title {
		font-size: 30rpx;
		font-weight: 700;
		line-height: 90rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.top-title:before {
		content: '';
		background: #FFFFFF;
		display: block;
		width: 8rpx;
		height: 8rpx;
		border: 4rpx solid rgb(74, 151, 248);
		border-radius: 8rpx;
		margin-right: 15rpx;
	}
	.tips {
		font-size: 28rpx;
		color: #FFFFFF;
		background: rgb(255, 163, 0);
		border-radius: 0rpx 30rpx 30rpx 30rpx;
		padding: 5rpx 28rpx;
	}
	.text {
		font-size: 28rpx;
		color: rgb(130, 130, 130);
		line-height: 50rpx;
	}
	.report {
		position: fixed;
		box-shadow: 0rpx 0rpx 17rpx 1rpx rgba(216, 216, 216, 0.68);
		bottom: 165rpx;
		right: 24rpx;
		width: 102rpx;
		height: 102rpx;
		border-radius: 102rpx;
		z-index: 99;
	}
	
	.publish-img {
		width: 100%;
		height: 100%;
		border-radius: 100%;
		box-shadow: 0rpx 0rpx 17rpx 1rpx rgba(216, 216, 216, 0.68);
	}
</style>
